//% color="#ef784c" iconWidth=50 iconHeight=40
namespace BaiduLicensePlate{

    //% block="初始化百度文字识别,API_KEY:[APIKEY],SECRET_KEY[SECRET]" blockType="command"
    //% APIKEY.shadow="string" APIKEY.defl=" "
    //% SECRET.shadow="string" SECRET.defl=" "
    export function baidu_licese_plate_init(parameter: any, block: any) {
        let key=parameter.APIKEY.code;
        let sceret_key=parameter.SECRET.code;
        Generator.addImport(`from baidu_handle import get_license_plate, get_baidu_access_token`)
        Generator.addCode(`BAIDU_LICENSE_PLATE_APIKEY = ${key}`)
        Generator.addCode(`BAIDU_LICENSE_PLATE_SECRETKEY = ${sceret_key}`)
        Generator.addCode(`BAIDU_LICENSE_PLATE_TOKEN = get_baidu_access_token(${key}, ${sceret_key})`)
    }

    //% block="读取文件[FILENAME],并识别车牌" blockType="reporter"
    //% FILENAME.shadow="string" FILENAME.defl="img.png"
    export function baidu_licese_plate_init_check(parameter: any, block: any) {
        let filename=parameter.FILENAME.code;
        Generator.addCode(`get_license_plate(BAIDU_LICENSE_PLATE_TOKEN, ${filename})`)
	}
